<?php
require_once 'FirePHPCore/fb.php';

class Rest {
	
	private $apiBaseUrl = NULL;
	private $apiAdminUrl = NULL;
	
	public function __construct() {
		$this->apiBaseUrl = 'http://localhost:8080/TestYourselfASE/rest/';
		$this->apiAdminUrl = 'http://localhost:8080/TestYourselfASE/rest/admin/';
	}
	
	
	// Szenario
	public function getScenarios() {	
		return json_decode(file_get_contents($this->apiBaseUrl.'scenarios'));		
	}
	public function changeScenario( $id, $scenarioName ) {
		return json_decode(file_get_contents($this->apiAdminUrl.'changeScenario/'.$id.'/'.$scenarioName));
	}
	public function addScenario( $scenarioName ){
		return json_decode(file_get_contents($this->apiAdminUrl.'addScenario/'.$scenarioName));
	}
	public function deleteScenario( $id ){
		return json_decode(file_get_contents($this->apiAdminUrl.'deleteScenario/'.$id));
	}
	// Categories	
	public function getAllCategories( ) {		
		return json_decode(file_get_contents($this->apiBaseUrl.'categories/getAllCategories/'));
	}
	public function getCategoriesToScenarios( $id ) {
		return json_decode(file_get_contents($this->apiBaseUrl.'categories/'.$id));
	}
	public function changeCategories( $id, $scenarioName ) {
		return json_decode(file_get_contents($this->apiAdminUrl.'changeCategory/'.$id.'/'.$scenarioName));
	}
	public function addCategory( $scenarioId, $categoryName ){
		return json_decode(file_get_contents($this->apiAdminUrl.'addCategory/'.$scenarioId.'/'.$categoryName));
	}
	public function deleteCategory( $id ){
		return json_decode(file_get_contents($this->apiAdminUrl.'deleteCategory/'.$id));
	}
	public function addCategoryToScenario( $scenarioId, $categoryId ){
		return json_decode(file_get_contents($this->apiAdminUrl.'addCategoryToScenario/'.$scenarioId.'/'.$categoryId));
	}
	public function deleteCategoryFromScenario( $scenarioId, $categoryId ){
		return json_decode(file_get_contents($this->apiAdminUrl.'deleteCategoryFromScenario/'.$scenarioId.'/'.$categoryId));
	}
	// Questions
	public function addQuestion( $categorieId, $severity, $questionName, $option1, $option2, $option3, $option4, $rightOptionNumber ) {
		$url = $this->apiAdminUrl.'addQuestion/'.$categorieId.'/'.$severity.'/'.$questionName.'/'.$option1.'/'.$option2.'/'.$option3.'/'.$option4.'/'.$rightOptionNumber;
		return json_decode(file_get_contents(urldecode($url)));
	}
	public function getAllQuestionsWithCategories() {
		return json_decode(file_get_contents($this->apiBaseUrl.'question/getAllQuestionsWithCategories'));
	}
	public function deleteQuestion($questionId) {
		return json_decode(file_get_contents($this->apiAdminUrl.'deleteQuestion/'.$questionId));
	}
	public function changeQuestion($questionId, $severity, $questionName, $option1, $option2, $option3, $option4, $rightOptionNumber) {
		$url = $this->apiAdminUrl.'changeQuestion/'.$questionId.'/'.$severity.'/'.$questionName.'/'.$option1.'/'.$option2.'/'.$option3.'/'.$option4.'/'.$rightOptionNumber;
		FB::log($url);
		return json_decode(file_get_contents($url));
	}
	public function addQuestionToCategory($categoryId, $questionId) {
		return json_decode(file_get_contents($this->apiAdminUrl.'addQuestionToCategory/'.$categoryId.'/'.$questionId));
	}
	public function deleteQuestionFromCategory($questionId, $categoryId) {
		return json_decode(file_get_contents($this->apiAdminUrl.'deleteQuestionFromCategory/'.$questionId.'/'.$categoryId));
	}
	
	
	
	
	
	
}